package com.medicine.manage.block.service.impl;

import com.medicine.manage.block.entity.WeBaseResult;
import com.medicine.manage.block.service.*;
import com.medicine.manage.domain.OrderDetail;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlockOrderDetailService extends AbstractBlockMultiplexService<OrderDetail> implements IBlockOrderDetailService {



    private final String INSERT_ORDER_DETAIL = "insertOrderDetail";
    private final String INSERT_ORDER_DETAILS = "insertOrderDetails";
    private final String SELECT_ORDER_DETAILS = "selectOrderDetailByOrderId";
    private final String SELECT_ORDER_DETAIL = "selectOrderDetailByOrderIdAndId";


    @Override
    public WeBaseResult insertOrderDetailList(List<OrderDetail> detailList, Long deptId, Long optionUserId) {
        return this.insertList(detailList, deptId,optionUserId, INSERT_ORDER_DETAILS);
    }

    @Override
    public WeBaseResult insertOrderDetail(com.medicine.manage.domain.OrderDetail orderDetail, Long deptId, Long optionUserId) {
        return this.insertOne(orderDetail, deptId, optionUserId, INSERT_ORDER_DETAIL);
    }

    @Override
    public WeBaseResult selectOrderDetailList(Long orderId, Long deptId, Long optionUserId) {
        return this.selectList(orderId, deptId, optionUserId, SELECT_ORDER_DETAILS);
    }

    @Override
    public WeBaseResult selectOrderDetail(Long orderId, Long detailId, Long deptId, Long optionUserId) {
        return this.selectOne(orderId, detailId, deptId, optionUserId, SELECT_ORDER_DETAIL);
    }


    @Override
    protected String createParam(OrderDetail o, Long optionUserId) {
        StringBuffer param = new StringBuffer();
        param.append(o.getOrderId()).append(IBlockService.SEPARATOR)
                .append(o.getId()).append(IBlockService.SEPARATOR)
                .append(o.getOptionType()).append(IBlockService.SEPARATOR)
                .append(o.getWeight()).append(IBlockService.SEPARATOR)
                .append(optionUserId);

        return param.toString();
    }
}
